package com.itheima.controller;

import com.itheima.dao.StudentDaoImpl;
import com.itheima.domian.Student;
import com.itheima.service.StudentService;
import com.itheima.service.StudentServiceImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class StudentControllerImpl implements StudentController {
     StudentService studentService  =  new StudentServiceImpl();


    @Override
    @Test
    public  void AllFindStudent() {
        List<Student> studentList = studentService.AllFindStudent();
        for (Student list :studentList){
            System.out.println(list.getSid()+","+list.getName()+","+list.getAge()+","+list.getBirthday());
        }
    }

    @Override
    @Test
    public void  findStudent() {
        Student student = studentService.findStudent(1);
        System.out.println(student);
    }

    @Override
    @Test
    public void addStudent() {
        Student student = new Student(10,"周氏",24,new Date());
        int add = studentService.addStudent(student);

        if(add!=-1){
            System.out.println("添加成功！");
        }else{
            System.out.println("添加失败！");
        }
    }

    @Override
    @Test
    public void updateStudent() {
        Student student = new Student(10,"周氏",24,new Date());

        int i = studentService.updateStudent(student ,1);

        if(i!=-1){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }
    }

    @Override
    @Test
    public void deleteStudent() {
        int delete = studentService.deleteStudent(4);
        if(delete!=-1){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }


}
